
typedef
struct{

	unsigned int trace_id;	//index into the first entry in trace
	unsigned int trace_length;			//length of current trace
	unsigned int completed_instructions;	//number of completed instructions
	unsigned int processing_element;	//processing element which is executing this trace
	unsigned int starting_pc;			//start pc of the trace
	bool valid;				//if valid trace is present
	bool exception;			//if any instruction in trace has an exception
	unsigned int exception_pc;		//the PC for instruction which raised an exception
	unsigned int exception_index;	//index at which we encountered exception

} trace_queue_entry_t;

class trace_queue {
	private:
		trace_queue_entry_t *tq;	// trace level active list
		unsigned int size;			// size of trace level active list
		unsigned int head;			// head pointer
		unsigned int tail;			// tail pointer
		int current_length;					// number of instructions in trace queue


	public:
		trace_queue(unsigned int size);		// constructor
		unsigned int push(unsigned int trace_index, unsigned int trace_length, unsigned int processing_element, unsigned int start_pc);		// push an instruction (its payload buffer index) into the trace queue
		unsigned int read_head_trace_id();			// pop the current trace's index
		unsigned int read_head_trace_length();			// pop the current trace's length
		void pop();			// free an entry in trace queue
		void flush();						// flush the trace queue (make it empty)
		bool trace_queue_empty();			// return if trace queue is empty
		bool trace_queue_full();			// return if trace queue is full
		bool head_trace_complete();			// returns if the trace at the head  of the queue has completed execution
		unsigned int get_head_processing_element();	//returns processing element ID for the head trace
		unsigned int get_starting_PC(unsigned int ID); //returns the starting pc of the trace in PE[ID]
		void inc_completed_inst(unsigned int ID);		//incremenet completed
		unsigned int get_pay_index(unsigned int ID);	//returns the index to pay.buf for the first instruction in trace in PE[ID]
		void clear_valid(unsigned int ID);				//clear valid bit on all entries
		bool free_if_last_PE(unsigned int ID);			//returns if last PE was/should be free
		void set_exception(unsigned int ID, unsigned int PC, unsigned int except_ind); 		//set exception PC and flag on the trace
		bool is_head_exception();			//check exception field on the trace
		unsigned int get_exception_PC();		//get exception field for current trace
		unsigned int get_exception_index();		//get exception index for the current trace
		unsigned int get_head_trace_length();	//get the length trace at q head
};
